package com.os.opencv.java.chapter3;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;

public class ReadFile {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //读取图像文件
        Mat src = Imgcodecs.imread("/Users/matt/MATT-MAC/matt_workspace/OS-OpenCV_workspace/test.jpg");

        //读取图像文件并转换成灰度图
        Mat grey = Imgcodecs.imread("/Users/matt/MATT-MAC/matt_workspace/OS-OpenCV_workspace/test.jpg", Imgcodecs.IMREAD_GRAYSCALE);

        //将灰度图像保存为图像文件
        Imgcodecs.imwrite("000176_grey.png", grey);

        //在屏幕上显示彩色图像和灰度图像
        HighGui.imshow("color", src);
        HighGui.waitKey(0);
        HighGui.imshow("grey", grey);
        HighGui.waitKey(0);
        System.exit(0);

    }
}
